package com.ruoyi.http.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.data.MD5;
import com.ruoyi.http.domain.WeChat00100T;
import com.ruoyi.http.service.IWeChatTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/http/weChat00100")
public class WeChat00100 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;
    @PostMapping("/weChat")
    public AjaxResult http(WeChat00100T weChat00100T) {
        WeChat00100T weChat = new WeChat00100T();
        if(weChat00100T.getHouseid().equals("")||weChat00100T.getPaperscode().equals("")) {
            String msg = "身份证号或房屋编号为空";
            return AjaxResult.error(msg);
        }else {
            weChat00100T.setPaperscode(MD5.md5(weChat00100T.getPaperscode()));
            weChat = weChatTService.getHouseIdByPapersCode(weChat00100T);
            weChatTService.updateOpenIdByHouseId(weChat00100T);
        }
        if(weChat==null) {
            String msg = "该户不存在";
            return AjaxResult.error(msg);
        }
        return AjaxResult.success(weChat);
    }
}